<template>
	<div>
		<div class="h2">活动审批</div>
		<!-- <a-tabs
		      default-active-key="1"
		      tab-position="top"
		      :style="{ height: '200px' }"
		      @prevClick="callback"
		      @nextClick="callback"
		    >
		      <a-tab-pane v-for="(item, i) in menuList" :key="i" :tab="item.Name + '(' + item.TotalItemCount + ')'"></a-tab-pane>
		    </a-tabs> -->
		<a-tabs default-active-key="1" class="leftmenuadd" tab-position="left" :style="{ height: '600px', width: '270px' }" @change="onetabChange">
			<a-tab-pane v-for="(item, i) in menuList" :key="i" :tab="item.Name + '(' + item.TotalItemCount + ')'"></a-tab-pane>
		</a-tabs>
		<a-tabs class="childtab" default-active-key="1" tab-position="top" @change="tabChange">
			<a-tab-pane v-for="(items, m) in approveList" :key="m" :tab="items.Name"></a-tab-pane>
		</a-tabs>
		<div class="childmain">
			<ActivityFlow1 v-show="tabkey == 0" :IsAgreeUpdate="IsAgreeUpdate" :flowTypeID="flowTypeID" ref="ActivityFlow1" @applyHander="applyHander"></ActivityFlow1>
			<ActivityFlow2 v-show="tabkey == 1" :IsAgreeUpdate="IsAgreeUpdate" :flowTypeID="flowTypeID" ref="ActivityFlow2"></ActivityFlow2>
		</div>

		<activityApplyExam :isShow="false" :text="text" :textArr="textArr" v-show="applyIf" @closeFun="closeFun"></activityApplyExam>
		
	</div>
</template>

<script>
import ActivityFlow1 from '../../components/ActivityFlow/ActivityFlow1.vue';
import ActivityFlow2 from '../../components/ActivityFlow/ActivityFlow2.vue';
import moment from 'moment';
import apply from './apply';
import activityApplyExam from '@/components/activityApplyExam';
import Func from '@/utils/func';
import { GetActivityStateList, GetClubPageListCommon, GetActivityFlowTypeListRoleActivityFlow, GetExamPageListActivityFlow } from '@/api/follow';
export default {
	components: {
		activityApplyExam,
		ActivityFlow1,
		ActivityFlow2
	},
	data() {
		return {
			applyIf: false,
			form: this.$form.createForm(this, {
				name: 'advanced_search'
			}),
			addIf: false,
			text: {},
			textArr:[],
			visible: false,
			confirmLoading: false,
			itemId: '',
			departmentList: [],
			worklist: [],
			tableHeight: parseFloat(window.innerHeight - 160),
			ActivityStateList: [],
			ClubList: [],
			tabkey: 0,
			menuList: [],
			flowTypeID: '',
			approveList: [
				{
					ID: 1,
					Name: '待审批'
				},
				{
					ID: 2,
					Name: '已审批'
				}
			],
			IsAgreeUpdate: false
		};
	},
	computed: {},
	created() {
		this.getList();
	},
	mounted() {},
	methods: {
		moment,
		callback(val) {
		},
		onetabChange(e) {
			// this.tabkey = 1
			this.flowTypeID = this.menuList[e].ID;
			this.IsAgreeUpdate = this.menuList[e].IsAgreeUpdate;
			// this.$refs.ActivityFlow1.getList();
			// this.$refs.ActivityFlow2.getList();
		},
		tabChange(e) {
			this.tabkey = e;
		},
		filterOption(input, option) {
			return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0;
		},
		async getList() {
			let res = await GetActivityFlowTypeListRoleActivityFlow();
			let list = res.data.data;
			for (let i = 0; i < list.length; i++) {
				let examList = await GetExamPageListActivityFlow({ flowTypeID: list[i].ID, pageIndex: 1, pageSize: 1 });
				list[i] = { ...list[i], TotalItemCount: examList.data.pageInfo.TotalItemCount };
			}
			this.menuList = list;
			this.flowTypeID = list[0].ID;
			this.IsAgreeUpdate = list[0].IsAgreeUpdate;
			// this.$nextTick(function () {
			//         this.$refs.ActivityFlow1.getList();
			// 				this.$refs.ActivityFlow2.getList();

			//       });
		},
		async fetchClub(value) {
			let myReg = /^[^a-zA-Z]+$/;
			if (value && value.length > 1) {
				let data = {};
				data.key = value;
				let res = await GetClubPageListCommon(data);
				this.ClubList = res.data.data;
			}
		},
		addList() {
			this.text = {};
			this.addIf = !this.addIf;
		},
		seeList(text, name) {
			let path = 'ActivityFlowDetail';
			this.$router.push({
				name: path,
				query: {
					ID: text.ID
				}
			});
		},
		applyHander(item) {
			if(Object.prototype.toString.call(item)=='[object Array]'){
				this.textArr = item;
			}else{
				this.text = item;
			}
			this.applyIf = true;
		},
		closeFun(data) {
			this.applyIf = false;
			if (data == 1) {
				this.$refs.ActivityFlow1.getList();
				this.$refs.ActivityFlow2.getList();
			}
		}
	}
};
</script>

<style lang="less" scoped>
.activemain {
	width: 100%;
	display: flex;
}
.flex-1 {
	flex: 1;
}
.menu {
	width: 80px;
}
.menuli {
	height: 40px;
	line-height: 40px;
	background: #3b90f8;
	color: #fff;
	text-align: center;
}
/deep/.ant-form-item {
	display: flex;
	margin-bottom: 10px !important;

	/deep/.ant-form-item-label {
		width: 80px;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		text-align: right;
	}
	/deep/.ant-form-item-control-wrapper {
		flex: 1;
	}
}
/deep/.el-table th.is-leaf {
	background: #fafafa;
}
/deep/.el-table td,
/deep/.el-table th {
	padding: 5px;
}
.option {
	margin-top: 10px;
	margin-bottom: 20px;
	overflow: hidden;
}
.option .btn {
	height: 36px;
	line-height: 36px;
	padding: 0 10px;
	float: left;
	background: #1890ff;
	color: #fff;
	margin-right: 10px;
	border-radius: 3px;
	cursor: pointer;
	border: none;
}
.foot {
	text-align: center;
	margin-top: 100px;
}
.el-pagination {
	margin-top: 10px;
}
.ant-form-item /deep/ .ant-form-item-control-wrapper {
	-webkit-box-flex: 1;
	-ms-flex: 1;
	flex: 1;
	min-width: 150px;
}
/deep/ .ant-form-item-control-wrapper {
	min-width: 200px;
}
.childtab {
	width: calc(~'100% - 270px');
	margin-left: 270px;
	margin-top: -600px;
}
.childmain {
	width: calc(~'100% - 270px');
	margin-left: 270px;
	margin-top: 0px;
}
.leftmenuadd{
	
}
/deep/.leftmenuadd .ant-tabs-tab{
	text-align: left !important;
}
/deep/.leftmenuadd .ant-tabs-bar{
	text-align: left !important;
}
/deep/.ant-tabs .ant-tabs-left-bar .ant-tabs-tab{
	padding: 8px 0px !important;
	white-space: pre-wrap;
}
</style>
